﻿using System;
using Bingosoft.Modules.SecurityConsole.Privilege;
using Bingosoft.Web.Utils;

namespace Bingosoft.WebApp.Modules.SecurityConsole.Privilege
{
    public partial class ModuleEdit : System.Web.UI.BasePage
    {
        private PrivilegeService _privilegeService;
        private PrivilegeService PrivilegeService
        {
            get
            {
                return _privilegeService ??
                       (_privilegeService = ObjectHelper.GetObject<PrivilegeService>("PrivilegeService"));
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack&&this.SmartFormView1.IsInsert())
            {
                this.SmartFormView1["Parent"] = Request.Params["ParentId"];
            }
        }

        protected void SaveModule(object sender, EventArgs e)
        {
            Module module = this.SmartFormView1.ToEntity<Module>();
            this.PrivilegeService.SaveOrUpdateModule(module);

            ScriptHelper.CloseDialog(this, "true");
        }
    }
}